package net.piggy.common.paging.page;

public class Page<T> implements IPage {
    // 页码
    private int pageNo = 1;
    // 每页数据行数
    private int pageSize = 10;
    // 总页数
    private int totalPage;
    // 数据总行数
    private int totalCount;
    private boolean isQueryTotal = true;
    private boolean isPaging = true;
    private long timestamp;
    private T data;

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
        int totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        this.setTotalPage(totalPage);
    }

    @Override
    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    @Override
    public boolean isQueryTotal() {
        return isQueryTotal;
    }

    public void setQueryTotal(boolean queryTotal) {
        isQueryTotal = queryTotal;
    }

    @Override
    public boolean isPaging() {
        return isPaging;
    }

    public void setPaging(boolean paging) {
        isPaging = paging;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

}
